/* eslint-disable class-methods-use-this */
import {
  post,
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Goods {
  async getGoodsList(page, limit, info) {
    const res = await get(`v1/goods?page=${page}&limit=${limit}`, info)
    return res
  }

  async getGoodsInfo(id) {
    const res = await get(`v1/goods/${id}`)
    return res
  }

  async createGoods(info) {
    const res = await post('v1/goods', info)
    return res
  }

  async updateGoods(info) {
    const res = await put('v1/goods', info)
    return res
  }

  async deleteGoods(id) {
    const res = await _delete(`v1/goods/${id}`)
    return res
  }

  async getGoodsSortList(page, limit, info) {
    const res = await get(`v1/goods_sort?page=${page}&limit=${limit}`, info)
    return res
  }

  async getGoodsSortAll(info) {
    const res = await get('v1/goods_sort_all', info)
    return res
  }

  async getGoodsSortInfo(id) {
    const res = await get(`v1/goods_sort/${id}`)
    return res
  }

  async createGoodsSort(info) {
    const res = await post('v1/goods_sort', info)
    return res
  }

  async updateGoodsSort(info) {
    const res = await put('v1/goods_sort', info)
    return res
  }

  async deleteGoodsSort(id) {
    const res = await _delete(`v1/goods_sort/${id}`)
    return res
  }
}

export default new Goods()
